package com.demo.springcache.common;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @Author: jxm
 * @Description:
 * @Date: 2022/5/15 12:07
 * @Version: 1.0
 */
@Data
public class CommonMessage {

    @ApiModelProperty(value = "从哪儿来", required = true, example = "ag")
    private String source;

    @ApiModelProperty(value = "类型", required = true, example = "binlog")
    private String type;

    @ApiModelProperty(value = "到哪儿去", required = true, example = "HDFS")
    private String sink;

    @ApiModelProperty(value = "存储位置", required = true, example = "fileName")
    private String location;

    @ApiModelProperty(value = "生成时间", example = "1034783346265")
    private long timestamp;

    @ApiModelProperty(value = "具体内容", required = true)
    private Object data;

    public void setTimestamp(long ts) {
        this.timestamp = ts == 0 ? System.currentTimeMillis() : ts;
    }

    public long getTimestamp() {
        return timestamp == 0 ? System.currentTimeMillis() : timestamp;
    }

    @Override
    public String toString() {
        return "CommonMessage{" +
                "source='" + source + '\'' +
                ", type='" + type + '\'' +
                ", sink='" + sink + '\'' +
                ", location='" + location + '\'' +
                ", timestamp=" + timestamp +
                ", data=" + data +
                '}';
    }
}
